package hr.ctg.domain.action;

import hr.ctg.util.StringUtil;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;

@Name("urlAction")
public class UrlAction {
	@In
	FacesContext facesContext;
	@In
	String currentLang;

	public String getUrl(final String url, final String title) {
		return ((HttpServletResponse) facesContext.getExternalContext()
				.getResponse()).encodeURL(facesContext.getExternalContext()
				.getRequestContextPath()
				+ url
				+ "&l="
				+ currentLang
				+ "&title="
				+ StringUtil.clearForUrl(title));
	}
}
